<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>逾期催收-结清价</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="sqPanel" style="margin-bottom: 0;">
        <div class="sqPanel_body">
            <div id="ligergrid1" class="sq-grid"></div>
        </div>   
    </div>
    <div id="pageInTab" class="pageInTab">
       <form id="prj_prd_veh_info_form">
           <div class="fieldset1 tabel_col clearFix">
		    	<div class="fieldBox col_33">
		            <div class="label">最大逾期天数 
		            </div>
		            <div class="field">
		                <span id="overdueDaysMax">&nbsp;</span>
		            </div>
		        </div>
		        <div class="fieldBox col_33">
		            <div class="label">实付合计
		            </div>
		            <div class="field">
		                <span id="paidUpAmtAll">&nbsp;</span>
		            </div>
		        </div>
		        <div class="fieldBox col_33">
		            <div class="label">应收金额合计（含罚息）
		            </div>
		            <div class="field">
		                <span id="arAmtAll">&nbsp;</span>
		            </div>
		        </div>
		        <div class="fieldBox col_33">
		            <div class="label">逾期租金合计 
		            </div>
		            <div class="field">
		                <span id="ovdAmtAll">&nbsp;</span>
		            </div>
		        </div>
		        <div class="fieldBox col_33">
		            <div class="label">待收罚息合计
		            </div>
		            <div class="field">
		                <span id="fineAmtAll">&nbsp;</span>
		            </div>
		        </div>
			   <div class="fieldBox col_33">
				   <div class="label">未来本金
				   </div>
				   <div class="field">
					   <span id="futureCapAmt">&nbsp;</span>
				   </div>
			   </div>
			   <div class="fieldBox col_33">
				   <div class="label">应收结清款金额
				   </div>
				   <div class="field">
					   <span id="recStlAmt">&nbsp;</span>
				   </div>
			   </div>
				<div class="fieldBox col_100" id="cp" style="display:none;">
		            <div class="label">提前结清价
		            </div>
		            <div class="field">
		                <span id="clearingPrice">&nbsp;</span>
		            </div>
		        </div>
	        </div>
        </form>
      </div>
</div>



<script type="text/javascript">
    var grid = null, form = null;
    var paySchId = "${paySchId}";
    var tableNm="${tableNm}";
    var arAmt=${arAmt};
    var ovdAmt=${ovdAmt};
    var fineAmt =${fineAmt};
    var overdueDay =${overdueDay};
	var futureCapAmt = ${futureCapAmt};
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/risk/overdueCollect/initOverdueClearingPriceList.do?queryType=1',
            parms:{paySchId:paySchId,tableNm:tableNm},
            method: 'get',
            columns: [
                {display: '支付表号', name: 'paySchNo', minWidth: 140, align: 'left', enabledSort: false},
                {display: '期数', name: 'payPd', minWidth: 80, align: 'center', enabledSort: false,
                	render:function(rowdata){
	                    if(rowdata.payPd&&rowdata.payPd!=0){
	                    	return rowdata.payPd;
	                    }else{
	                    	return "";
	                    }     	
                    }	
                },
                {display: '应收类型', name: 'feeTypeCd', width: 140, align: 'center', enabledSort: false,
                	render:function(rowdata){
	                    if(rowdata.payPd&&rowdata.payPd!=0){
	                    	return "第"+rowdata.payPd + "期"+rowdata.feeTypCdNm;
	                    }else{
	                    	return rowdata.feeTypCdNm;
	                    }     	
                    }
                },
                {display: '应还日期', name: 'payDt', width: 140, align: 'center', enabledSort: false,render:renderDate},
                {
                    display: '应收款', name: 'feeAmt', width: 140, align: 'center', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.feeAmt / 100);
                    },totalSummary:{
                        render:function (suminf,column,cell) {
                        	$("#overdueAmtAll").html("&yen;"+FormatMoney(suminf.sum / 100));
                            
                        }
                    }
                },
                {
                    display: '实付款', name: 'paidUpAmt', width: 140, align: 'center', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.paidUpAmt / 100);
                    },totalSummary:{
                        render:function (suminf,column,cell) {
                        	$("#paidUpAmtAll").html("&yen;"+FormatMoney(suminf.sum / 100));
                  
                        }
                    }
                },
                {display: '逾期天数', name: 'ovdDays', width: 80, align: 'center', enabledSort: false,
                	render: function (rowdata, index, value) {
                		if(rowdata.feeTypCd!='S01'){
                			return '';
                		}else{               			
                			if(rowdata.ovdDays<=0){
                				return '';
                			}else{               				
                				return rowdata.ovdDays-1;
                			}
                		}
                	}
                },
                {
                	display: '操作', name: 'prdStsCd', width: 160 ,
                	render:function(rowdata,index,value){
                    	return '<a class="sq-button-hasicon" style="cursor: pointer;" onclick="showDetail(' + rowdata.id + ','+rowdata.payPd+');"><i class="sqBtnIco_49"></i>实付明细</a>  ' ;
            		}
                }

            ],
            pageSize: 50,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '70%',
            heightDiff: -2,
            allowUnSelectRow: false,
            alternatingRow: false,
        });
        grid.setHeight(100);
        
        $("#overdueDaysMax").html(overdueDay);
        $("#arAmtAll").html("&yen;"+FormatMoney(arAmt/100));
        $("#ovdAmtAll").html("&yen;"+FormatMoney(ovdAmt/100));
        $("#fineAmtAll").html("&yen;"+FormatMoney(fineAmt/100));
		$("#futureCapAmt").html("&yen;"+FormatMoney(futureCapAmt/100));
		$("#recStlAmt").html("&yen;"+FormatMoney(futureCapAmt/100 + arAmt/100));
        $("#pageloading").hide();
        getFinalPayAmt(paySchId);//提前结清价
    });

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
    //实付详情
    function showDetail(payDetailId,payPd){
    	parent.parent.mainApp.f_addTab('tab_overdue_capfundvfdtl','实付详情','<%=path%>/risk/overdueCollect/toOverdueCapFundVfDtlPage.do?payDetailId=' + payDetailId+'&paySchId='+paySchId+'&payPd='+payPd);
    }
    function applyCarPreSett(id,prjId,payPd,startLsPd,paySchNo){
    	var callback = function(){
    		 grid.reload();
    	}
    	var params = {};
    	params.paySchId = id;
    	params.sett = "pre";
    	$.ajax({
    		type: 'post',
    		dataType:'json',
    		data:params,
    		url: '<%=path%>/project/prjprdpayschm/checkPrjPaySchFlag.do',
    		success:function(msg){
    			 if(msg.success == 1){
    					Add_navTab('tab_prj_quat_prps_pre_sett'+id,'支付表提前结清信息详情','<%=path%>/project/prjprdpayschm/showCarPreSettlePage.do?paySchId='+id+'&&prjId='+prjId+'&&payPd='+payPd+'&&startLsPd='+startLsPd+'&&paySchNo='+paySchNo,callback);
    			 }else{
    				 UIUtils.alertErrorHold1(msg.info);
    			 }
    		}
    	});
    }
    function applyPerSett(id,prjId,payPd,startLsPd,paySchNo){
    	var callback = function(){
    		 grid.reload();
    	}
    	var params = {};
    	params.paySchId = id;
    	params.sett = "pre";
    	$.ajax({
    		type: 'post',
    		dataType:'json',
    		data:params,
    		url: '<%=path%>/project/prjprdpayschm/checkPrjPaySchFlag.do',
    		success:function(msg){
    			 if(msg.success == 1){
    					Add_navTab('tab_prj_quat_prps_pre_sett'+id,'支付表提前结清信息详情','<%=path%>/project/prjprdpayschm/showChoosePreSettlePdPage.do?paySchId='+id+'&&prjId='+prjId+'&&payPd='+payPd+'&&startLsPd='+startLsPd+'&&paySchNo='+paySchNo,callback);
    			 }else{
    				 UIUtils.alertErrorHold1(msg.info);
    			 }
    		}
    	});
    }
    
    
    
  	//提前结清价
    function getFinalPayAmt(paySchId){
    	$.ajax({
            type: 'get',
            dataType: 'json',
            url: '<%=path%>/risk/overdueCollect/getfinalPayAmt.do?paySchId='+paySchId+'&tableNm='+tableNm+'&ovdAmt='+ovdAmt+'&fineAmt='+fineAmt,
            success: function (msg) {
                if (msg.success == 1) {
                    var h2="";
                    if(tableNm == "PRJ_PRD_PAY_SCH_M"){
                    	if(msg.data.buOrgCd==ProjectConstant.CODE_BU_ORG_CD_CAR){
                    		h2+='<a class="link" style="cursor: pointer;" href="javascript:applyCarPreSett(';
                            h2+="'"+msg.data.id+"',";
                            h2+="'"+msg.data.prjId+"',";
                            h2+="'"+msg.data.lsPd+"',";
                            h2+="'"+msg.data.startLsPd+"',";
                            h2+="'"+msg.data.paySchNo+"'";
                            h2+=')">查看提前结清价</a>';
                    	}else if(msg.data.buOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZK||msg.data.buOrgCd==ProjectConstant.CODE_BU_ORG_CD_YC||msg.data.buOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZC){
                    		h2+='<a class="link" style="cursor: pointer;" href="javascript:applyPerSett(';
                            h2+="'"+msg.data.id+"',";
                            h2+="'"+msg.data.prjId+"',";
                            h2+="'"+msg.data.lsPd+"',";
                            h2+="'"+msg.data.startLsPd+"',";
                            h2+="'"+msg.data.paySchNo+"'";
                            h2+=')">查看提前结清价</a>';
                    	}
                    	$("#clearingPrice").html(h2);
                    	if(h2!=""){
                    		$("#cp").show();
                    	}	
                    }
                }
            }
        });
    }
</script>

</body>
</html>
